/**
 *
 * User: Zhikang.Peng
 * Date: 2018/04/13 15:35
 */
package extended

import (
	"gitee.com/thghh/jvmgo/instructions/base"
	"gitee.com/thghh/jvmgo/rtda"
)

// 若栈顶引用值为null则跳转
type IFNULL struct{ base.BranchInstruction }

func (self *IFNULL) Execute(frame *rtda.Frame) {
	ref := frame.OperandStack().PopReference()
	if ref == nil {
		base.Branch(frame, self.Offset)
	}
}

// 若栈顶引用值不为null则跳转
type IFNONNULL struct{ base.BranchInstruction }

func (self *IFNONNULL) Execute(frame *rtda.Frame) {
	ref := frame.OperandStack().PopReference()
	if ref != nil {
		base.Branch(frame, self.Offset)
	}
}
